import Vue from 'vue'
import VueRouter from 'vue-router'

import Layout from '@/views/layout'
import Home from '@/views/layout/home'
import Category from '@/views/layout/category'
import Cart from '@/views/layout/cart'
import User from '@/views/layout/user'

import store from '@/store'

const Search = () => import('@/views/search')
const SearchList = () => import('@/views/search/list')
const ProDetail = () => import('@/views/prodetail')
const Login = () => import('@/views/login')
const Pay = () => import('@/views/pay')
const MyOrder = () => import('@/views/myorder')
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    component: Login
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        component: Home
      },
      {
        path: 'category',
        component: Category
      },
      {
        path: 'solutionInfo',
        component: () => import('@/views/solution/solutionInfo/index')
      },
      {
        path: 'online',
        component: () => import('@/views/layout/online')
      },
      {
        path: 'user',
        component: User
      },
    ]
  },
  {
    path: '/search',
    component: Search
  },
  {
    path: '/searchlist',
    component: SearchList
  },
  {
    path: '/prodetail/:id',
    component: ProDetail
  },
  {
    path: '/pay',
    component: Pay
  },
  {
    path: '/myorder',
    component: MyOrder
  },
  /* 线上鉴权 --------------------- 开始 */
  // 线上鉴权
  {
    path: '/onlineAuth',
    component: () => import('@/views/online/onlineAuth/index')
  },
  // 线上建档 - 小微
  {
    path: '/onlineFilingXw',
    component: () => import('@/views/online/onlineFiling/xw/index')
  },
  // 线上建档 - 法人单位
  {
    path: '/onlineFilingLegalEntity',
    component: () => import('@/views/online/onlineFiling/legalEntity/index')
  },
  // 授权管理
  {
    path: '/authManage',
    component: () => import('@/views/online/authManage/index')
  },
  /* 线上鉴权 --------------------- 结束 */
  /* 业务办理 --------------------- 开始 */
  // 立即办理
  {
    path: '/immediateProcessing',
    component: () => import('@/views/businessProcessing/immediateProcessing/index')
  },
  // 支付
  {
    path: '/payment',
    component: () => import('@/views/businessProcessing/immediateProcessing/component/index')
  },
  // oao模式办理
  {
    path: '/oaoModeProcessing',
    component: () => import('@/views/businessProcessing/oaoModeProcessing/index')
  },
  // 甩单
  {
    path: '/shuffleOrders',
    component: () => import('@/views/businessProcessing/shuffleOrders/index')
  },
  // 甩单处理
  /* {
    path: '/disposalOfOrders',
    component: () => import('@/views/businessProcessing/shuffleOrders/index')
  }, */
  // 甩单处理详情
  {
    path: '/disposalOfOrdersDetail',
    component: () => import('@/views/businessProcessing/shuffleOrders/component/index')
  },
  // 商机预约
  {
    path: '/businessOpportunityAppointment',
    component: () => import('@/views/businessProcessing/businessOpportunityAppointment/index')
  },
  // 商机预约 - 详情
  {
    path: '/appointmentDetail',
    component: () => import('@/views/businessProcessing/businessOpportunityAppointment/component/index')
  },
  // 支付成功
  {
    path: '/businessPaySuccess',
    component: () => import('@/views/common/paySuccess.vue')
  },
  /* 业务办理 --------------------- 结束 */
  /* 产品管理 --------------------- 开始 */
  {
    path: '/productDetail',
    component: () => import('@/views/productLibrary/productDetail/index.vue')
  },
  {
    path: '/immediateProcessingDetail',
    component: () => import('@/views/productLibrary/immediateProcessingDetail/index')
  },
  {
    path: '/confirmOrder',
    component: () => import('@/views/productLibrary/confirmOrder/index')
  },
  {
    path: '/announcement',
    component: () => import('@/views/productLibrary/announcement/index')
  },
  {
    path: '/hotWords',
    component: () => import('@/views/productLibrary/hotWords/index')
  },
  /* 产品管理 --------------------- 结束 */
  {
    path: '/solutionDetail',
    component: () => import('@/views/solution/solutionDetail/index')
  },
  // 消息通知
  {
    path: '/messageNotice',
    component: () => import('@/views/message/index')
  },
  // 活动列表
  {
    path: '/activeList',
    component: () => import('@/views/hotActives/activeList/index')
  },
  // 活动详情
  {
    path: '/activeDetail',
    component: () => import('@/views/hotActives/activeDetail/index')
  },
  // 基础服务
  {
    path: '/servicesManage',
    component: () => import('@/views/basicServices/servicesManage/index')
  },
  /* 客户自助服务展示 --------------------- 开始 */
{
    path: '/invoice',
    component: () => import('@/views/Customer/invoice/invoice')
  },
  {
    path: '/invoiceIssuance',
    component: () => import('@/views/Customer/invoice/invoiceIssuance')
  },
   {
    path: '/invoiceAnce',
    component: () => import('@/views/Customer/invoice/invoiceAnce')
  },
   {
    path: '/invoiceAnce2',
    component: () => import('@/views/Customer/invoice/invoiceAnce2')
  },
    {
    path: '/complainPage',
    component: () => import('@/views/Customer/complain/complainPage')
  },
    {
    path: '/complainPageView',
    component: () => import('@/views/Customer/complain/complainPageView')
  },





  /* 客户自助服务展示 --------------------- 结束 */
]

const router = new VueRouter({
  routes
})
/* router.beforeEach((to, from, next) => {
  const authUrl = ['/pay', '/myorder']
  const token = store.getters.token
  if (!authUrl.includes(to.path)) {
    next()
    return
  }
  if (token) {
    next()
  } else {
    next('/login')
  }
}) */

export default router
